<form class="form-inline" action="<?=printUrl('Main','adminSubScore')?>" name="subScore" id="subScore">
<table border="1" cellspacing="0" class="table table-hover table-bordered table-condensed">
  <thead>
    <tr>
      <th class="bg-primary text-center" rowspan="2">地区</th>
      <th class="bg-primary text-center" rowspan="2">大区</th>
      <th class="bg-primary text-center" rowspan="2">小区</th>
      <th class="bg-primary text-center" rowspan="2">城市</th>
      <th class="bg-primary text-center" rowspan="2">编码</th>
      <th class="bg-primary text-center" rowspan="2">专营店</th>
      <th class="bg-primary text-center" colspan="3">双月预算明细</th>
      <th class="bg-primary text-center" colspan="13">双月结算明细</th>
    </tr>
    <tr>
      <th class="bg-primary text-center">双月额度</th>
      <th class="bg-primary text-center">预算申请金额</th>
      <th class="bg-primary text-center">预算审核金额</th>
      <th class="bg-primary text-center">结算申请金额</th>
      <th class="bg-primary text-center">结算审核金额</th>
      <th class="bg-primary text-center">可结算金额</th>
      <th class="bg-primary text-center">活动评比系数</th>
      <th class="bg-primary text-center">结算金额</th>
      <th class="bg-primary text-center">补报预算申请金额</th>
      <th class="bg-primary text-center">补报预算审核金额</th>
      <th class="bg-primary text-center">补报结算申请金额</th>
      <th class="bg-primary text-center">补报结算审核金额</th>
      <th class="bg-primary text-center">补报可结算金额</th>
      <th class="bg-primary text-center">补报扣罚金额</th>
      <th class="bg-primary text-center">补报结算金额</th>
      <th class="bg-primary text-center">最终结算总额</th>
    </tr>
  </thead>
  <tbody>
    <?php
    foreach ($procList as $k => $v) {
    ?>
    <tr>
      <td class="text-center"><?=isset($allStoreList[$v['storeId']]) ? $allStoreList[$v['storeId']]['area'] : ''?></td>
      <td class="text-center"><?=isset($allStoreList[$v['storeId']]) ? $allStoreList[$v['storeId']]['region'] : ''?></td>
      <td class="text-center"><?=isset($allStoreList[$v['storeId']]) ? $allStoreList[$v['storeId']]['spsarea'] : ''?></td>
      <td class="text-center"><?=isset($allStoreList[$v['storeId']]) ? $allStoreList[$v['storeId']]['city'] : ''?></td>
      <td class="text-center"><?=isset($allStoreList[$v['storeId']]) ? $allStoreList[$v['storeId']]['coding'] : ''?></td>
      <td class="text-center"><?=isset($allStoreList[$v['storeId']]) ? $allStoreList[$v['storeId']]['storeName'] : ''?></td>
      <td class="text-center"><?=$v['fixedMoney']?></td>
      <td class="text-center"><?=$v['budgetApply']?></td>
      <td class="text-center"><?=$v['budgetAudit']?></td>
      <td class="text-center"><?=$v['settleApply']?></td>
      <td class="text-center"><?=$v['settleAudit']?></td>
      <td class="text-center"><?=$v['canSettleMoney']?></td>
      <td class="text-center">
          <?php
          if($subType == 'query' && $this->auth->isSingleSettleSubScore($v) ){
          $v['score'] = (float)$v['score'] == 0 ? '1.0' : $v['score'];
          ?>
          <div class="input-group">
            <select class="input-sm" name="subData[<?=$v['id']?>][score]" id="score_<?=$v['id']?>">
              <?php for($i=0.6; $i<=1.0; $i+=0.1){ ?>
              <option value="<?=$i?>" <?php echo (string)$i==(string)$v['score'] ? 'selected="selected"' : ''?>><?=$i?></option>
              <?php } ?>
            </select>
              <button class="btn btn-default btn-sm" onclick="ajaxConfirmSubmit('您确定提交此活动评分系数么？','<?=printUrl('Main','adminSubScore')?>',{'subData':{<?=$v['id']?>:{'score':$('#score_<?=$v['id']?>').val()} } })" type="button"><?=$v['score'] > 0 ? '修改提交' : '请提交'?></button>
          </div><!-- /input-group -->
          <?php }else{ echo (float)$v['score'] ? $v['score'] : '未评分'; } ?>
      </td>
      <td class="text-center"><?=$v['settleMoney']?></td>
      <td class="text-center"><?=$v['buBudgetApply']?></td>
      <td class="text-center"><?=$v['buBudgetAudit']?></td>
      <td class="text-center"><?=$v['buSettleApply']?></td>
      <td class="text-center"><?=$v['buSettleAudit']?></td>
      <td class="text-center"><?=$v['buCanSettleMoney']?></td>
      <td class="text-center"><?=$v['buLoseMoney']?></td>
      <td class="text-center" class="text-center"><?=$v['buSettleMoney']?></td>
      <td class="text-center"><?=$v['finalSettleMoney']?></td>
    </tr>
    <?php } ?>
    <?php if($subType == 'query' && $this->auth->isSingleSettleSubScore($v)){ ?>
    <tr>
      <td colspan="19">
        <div class="row">
          <div class="col-md-1  col-md-offset-5">
            <button class="btn btn-default btn-sm" type="button" onclick="ajaxFormSubmit('subScore')">批量提交</button>
          </div>
        </div>
      </td>
    </tr>
    <?php } ?>
    <?php
    $total = getArrayColumnTotal($procList,
        array('budgetApply','budgetAudit','fixedMoney','settleApply','settleAudit','canSettleMoney',
            'score','settleMoney','buBudgetApply','buBudgetAudit','buSettleApply','buSettleAudit',
            'buCanSettleMoney','buLoseMoney','buSettleMoney','finalSettleMoney'),1);
    ?>
    <tr>
      <td class="text-center" colspan="6">合计</td>
      <td class="text-center"><?=$total['fixedMoney']?></td>
      <td class="text-center"><?=$total['budgetApply']?></td>
      <td class="text-center"><?=$total['budgetAudit']?></td>
      <td class="text-center"><?=$total['settleApply']?></td>
      <td class="text-center"><?=$total['settleAudit']?></td>
      <td class="text-center"><?=$total['canSettleMoney']?></td>
      <td class="text-center">
        <?php
        $count = count($procList);
        echo $count ? round((float)$total['score']/$count,2) : 0;
        ?>
      </td>
      <td class="text-center"><?=$total['settleMoney']?></td>
      <td class="text-center"><?=$total['buBudgetApply']?></td>
      <td class="text-center"><?=$total['buBudgetAudit']?></td>
      <td class="text-center"><?=$total['buSettleApply']?></td>
      <td class="text-center"><?=$total['buSettleAudit']?></td>
      <td class="text-center"><?=$total['buCanSettleMoney']?></td>
      <td class="text-center"><?=$total['buLoseMoney']?></td>
      <td class="text-center"><?=$total['buSettleMoney']?></td>
      <td class="text-center"><?=$total['finalSettleMoney']?></td>
    </tr>
  </tbody>
</table>
</form>